import { ListNode } from './listNode.js'
import { Solution } from './solution.js'

let l1 = [1, 2, 6, 3, 4, 5, 6]
const val1 = 6

let l2 = [7, 7, 7]
const val2 = 7

let l3 = []

let t = function(l, val, func) {
    let head = ListNode.initWithList(l)
    if (head != null) {
        console.log(`before: ${head.description()}`) 
    }else {
        console.log('before: null')
    }
    let result = func(head, val)
    if (result != null) {
        console.log(`after: ${result.description()}`) 
    }else {
        console.log("after: null")
    }
}

console.log("----------cycle----------")
t(l1, val1, Solution.removeElements)
t(l2, val2, Solution.removeElements)
t(l3, val2, Solution.removeElements)
console.log("----------recursion----------")
t(l1, val1, Solution.removeElementsByRecursion)
t(l2, val2, Solution.removeElementsByRecursion)
t(l3, val2, Solution.removeElementsByRecursion)